#Makefile fuer linux
# $<	erste Abhängigkeit
# $@	Name des Targets
# $+	Liste aller Abhängigkeiten
# $^	^^ ohne Wiederholungen

.PHONY: clean all btf btf_clean

TARGET = ./spike

CC = g++
CFLAGS = -Wall -pedantic -ansi -g #-DVALGRIND
CXX = $(CC) $(CFLAGS)
LD = $(CC)
LIBS = -lGL -lGLU -lglut

all: $(TARGET)

$(TARGET): bin/Assembly.o bin/Color.o bin/Cuboid.o bin/Cylinder.o bin/Face.o bin/Material.o bin/MaterialLib.o bin/Matrix4D.o bin/Sphere.o bin/Vertex.o bin/WaveObj.o bin/main.o
	@echo ... LINKING ...
	$(LD) $(LIBS) $^ -o $@

bin/main.o: main.cpp
	$(CXX) -c $< -o $@

bin/%.o: %.cpp %.h
	$(CXX) -c $< -o $@

run: $(TARGET)
	$(TARGET)

btf:
	astyle --style=linux --indent=tab --mode=c -b -U -E ./*.cpp ./*.h

btf_clean:
	find ./ -name "*.orig" -print0 | xargs -0 rm -f

clean:  btf_clean
	rm -f bin/*.o $(TARGET)

